<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/header.css" />
		<style>
			.mui-content{
				width: 100%;
				position: absolute;
				top: 44px;
				bottom: 0px;
				background: #2e3132;
			}
		</style>
	</head>

	<body>
		
		<header class="mui-bar mui-bar-nav title" style="position: fixed;">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left title-color"></a>
		    <a id="down_qr_code" class="mui-pull-right" style="font-size: 15px;line-height: 44px;margin-top: 7px;">
		    	<img src="../../img/down.png" width="30px" />
		    </a>
		    <h1 class="mui-title title-color">我的二维码名片</h1>
		</header>
		
		<div class="mui-content" style="padding: 80px 30px 0px 30px;">
			<div style="background-color: white;padding-top: 20px; padding-left: 20px;">
				<img id="iconImg" src="" width="50px" height="50px" style="border-radius: 5px;"/>
				<label style="margin-left: 10px;color: #8F8F94;font-size: 14px;height: 44px;line-height: 44px;">嗨聊号:<span id="username"></span></label>
			</div>
			<div style="background-color: white;text-align: center;">
				<!--<img id="iconImg" src="http://47.104.240.41:8080/group1/M00/00/00/rB-wnVvsRZCACaQbAAAhrUNGHTI534.jpg" style="width: 70%;height: 70%;"/>-->
	          	<img id="myQrCodeImg" src=""/>
	          	<br/>
	          	<label style="font-size: 14px;color: #929292;">扫一扫上面的二维码，加我好友</label>
			</div>
		</div>
		
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../js/app.js" ></script>
		<script type="text/javascript">
			mui.init()
			
			mui.plusReady(function() {
				plus.navigator.setStatusBarStyle("light");
	      		plus.navigator.setStatusBarBackground("#4eabe8");
	      		
	      		//获取用户信息
				var currentView = plus.webview.currentWebview();
				currentView.addEventListener("show", function() {
					getQrCodeInfo();
				});
				
				var down = document.getElementById("down_qr_code");
				down.addEventListener("tap", function() {
					plus.nativeUI.showWaiting("下载中...");
					var task = plus.downloader.createDownload(
						app.getUserInfo().qrCode,
						{},
						function(d, status) {
							plus.nativeUI.closeWaiting();
							if(status == 200) {
								plus.gallery.save(d.filename, function(){
									app.showToast("图片已保存至相册", "success");
								})
							}
						}
					)
					task.start();
				});
	      		
			});
			
			function getQrCodeInfo() {
				var userInfo = app.getUserInfo();
				var imageIcon = userInfo.avatar;
				var myQrCodeImg = userInfo.qrCode;
				var username = userInfo.username;
				document.getElementById("username").innerHTML = username;
				document.getElementById("iconImg").src = imageIcon;
				document.getElementById("myQrCodeImg").src = myQrCodeImg;
				
				var imgWidth = document.body.clientWidth - 100;
				document.getElementById("myQrCodeImg").width = imgWidth;
				document.getElementById("myQrCodeImg").height = imgWidth;
			}
		</script>
	</body>

</html>